// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement.  The various license agreements may be found at
// the Magic Software web site.  This file is subject to the license
//
// RESTRICTED USE SOURCE CODE
// http://www.magic-software.com/License/restricted.pdf

#include "MgcFogState.h"

MgcImplementRTTI(MgcFogState,MgcRenderState);
MgcImplementStream(MgcFogState);
MgcImplementDefaultState(MgcFogState);

//----------------------------------------------------------------------------
MgcRenderState::Type MgcFogState::GetType () const
{
    return RS_FOG;
}
//----------------------------------------------------------------------------
MgcFogState::MgcFogState ()
    :
    m_kColor(MgcColor::BLACK)
{
    m_bEnabled = false;
    m_fStart = 0.0;
    m_fEnd = 1.0;
    m_fDensity = 1.0;
    m_eDFunction = DF_LINEAR;
    m_eAFunction = AF_PER_VERTEX;
}
//----------------------------------------------------------------------------

//---------------------------------------------------------------------------
// streaming
//---------------------------------------------------------------------------
MgcObject* MgcFogState::Factory (MgcStream& rkStream)
{
    MgcFogState* pkObject = new MgcFogState;
    MgcStream::Link* pkLink = new MgcStream::Link(pkObject);
    pkObject->Load(rkStream,pkLink);
    return pkObject;
}
//---------------------------------------------------------------------------
void MgcFogState::Load (MgcStream& rkStream, MgcStream::Link* pkLink)
{
    MgcRenderState::Load(rkStream,pkLink);

    // native data
    MgcStreamRead(rkStream,m_bEnabled);
    MgcStreamRead(rkStream,m_fStart);
    MgcStreamRead(rkStream,m_fEnd);
    MgcStreamRead(rkStream,m_fDensity);
    MgcStreamRead(rkStream,m_kColor);
    MgcStreamRead(rkStream,m_eDFunction);
    MgcStreamRead(rkStream,m_eAFunction);
}
//---------------------------------------------------------------------------
void MgcFogState::Link (MgcStream& rkStream, MgcStream::Link* pkLink)
{
    MgcRenderState::Link(rkStream,pkLink);
}
//---------------------------------------------------------------------------
bool MgcFogState::Register (MgcStream& rkStream)
{
    return MgcRenderState::Register(rkStream);
}
//---------------------------------------------------------------------------
void MgcFogState::Save (MgcStream& rkStream)
{
    MgcRenderState::Save(rkStream);

    // native data
    MgcStreamWrite(rkStream,m_bEnabled);
    MgcStreamWrite(rkStream,m_fStart);
    MgcStreamWrite(rkStream,m_fEnd);
    MgcStreamWrite(rkStream,m_fDensity);
    MgcStreamWrite(rkStream,m_kColor);
    MgcStreamWrite(rkStream,m_eDFunction);
    MgcStreamWrite(rkStream,m_eAFunction);
}
//---------------------------------------------------------------------------
